package save;

import quads.MarchQuad;
import march.Timekeeper;

public class LaunchEvent extends PerformanceEvent {

	/**
	 * 
	 */
	private static final long serialVersionUID = -732738112532436276L;
	private int row;
	private int col;
	private String className;
	private MarchQuad quad;
	
	public LaunchEvent(int timestep, int row, int col, String className) {
		super(timestep);
		this.row = row;
		this.col = col;
		this.className = className;
	}
	
	@Override
	public void execute() {
		
		Timekeeper.get().getGridCanvas().launchQuad(row, col, quad);

	}

	@SuppressWarnings("unchecked")
	@Override
	public void unpack() {
		try {
			Class<? extends MarchQuad> cls =  (Class<? extends MarchQuad>) Class.forName(className);
			Object[] args = new Object[1];
			
			quad = cls.getConstructor(boolean[][].class).newInstance(args);
			
			
		} catch (Exception e) {
			
			e.printStackTrace();
		}
		
	}

}
